package com.zy.service.impl;

import com.zy.dao.SalaryDao;
import com.zy.dao.impl.SalaryDaoImpl;
import com.zy.pojo.Salary;
import com.zy.service.SalaryService;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xiaoqi
 * Date: 2021-06-11
 * Time: 下午 16:31
 * Description: 工资服务层接口实现类
 */
public class SalaryServiceImpl implements SalaryService {
    private SalaryDao salaryDao = new SalaryDaoImpl();

    @Override
    public boolean insertSalary(Salary salary) {

        return salaryDao.insertSalary(salary) > 0;
    }

    @Override
    public List<Salary> getSalaryListByPage(Salary salary) {
        if (salary.getStart() != null) {
            salary.setStart((salary.getStart() - 1) * salary.getLimit());
        }
        return salaryDao.getSalaryListByPage(salary);
    }

    @Override
    public Integer getSalaryCount(Salary salary) {

        return salaryDao.getSalaryCount(salary);
    }

    @Override
    public boolean updateSalary(Salary salary) {

        return salaryDao.updateSalary(salary) > 0;
    }

    @Override
    public Salary getSalaryByEmpId(Integer empId) {
        return salaryDao.getSalaryByEmpId(empId);
    }
}